<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>视频会议弹幕</title>
    <script>
        // 建立 WebSocket 连接
        var socket = new WebSocket("ws://localhost:8080/ws");

        socket.onmessage = function(event) {
            var messageBoard = document.getElementById('messageBoard');
            var newMessage = document.createElement('div');
            newMessage.innerText = event.data;
            messageBoard.appendChild(newMessage);
        };

        function sendMessage() {
            var input = document.getElementById('messageInput');
            socket.send(input.value);
            input.value = '';
        }
    </script>
</head>
<body>
<div id="messageBoard" style="border: 1px solid black; height: 300px; overflow-y: scroll;"></div>
<input type="text" id="messageInput" />
<button onclick="sendMessage()">发送</button>
</body>
</html>